<?php

defined('SYSPATH') or die('No direct access allowed.');

/**
 * Service Activity
 */
class Model_Service_Activity_User_Log extends Domain_Dao_Activity_User_Log {

    public $_rep;

    const ACTION_USER_ACTIVE = "USER_ACTIVE";
    const ACTION_USER_INACTIVE = "USER_INACTIVE";
    
    const ACTION_USER_LOGIN = "LOGIN";
    const ACTION_USER_LOOUT = "LOGOUT";
    const ACTION_USER_UPDATE_PROFILE = "UPDATE_PROFILE";

    const ACTION_USER_CUSTOMER_ADD = "ADD_CUSTOMER";
    const ACTION_USER_CUSTOMER_EDIT = "EDIT_CUSTOMER";
    const ACTION_USER_CUSTOMER_DELETE = "DELETE_CUSTOMER";

    const ACTION_USER_USER_ADD = "ADD_USER";
    const ACTION_USER_USER_EDIT = "EDIT_USER";
    const ACTION_USER_USER_DELETE = "DELETE_USER";

    const ACTION_USER_GROUP_ADD = "ADD_GROUP";
    const ACTION_USER_GROUP_EDIT = "EDIT_GROUP";
    const ACTION_USER_GROUP_DELETE = "DELETE_GROUP";

    const ACTION_USER_CHANGE_PASSWORD = "CHANGE_PASSWORD_USER";

    const ACTION_CUSTOMER_CHANGE_PASSWORD = "CHANGE_PASSWORD_CUSTOMER";
    
    const ACTION_USER_QUESTION_ADD = "ADD_QUESTION";
    const ACTION_USER_QUESTION_EDIT = "EDIT_QUESTION";
    const ACTION_USER_QUESTION_DELETE = "DELETE_QUESTION";
    
    const ACTION_MAIL_TEMPLATE_ADD = "ADD_MAIL_TEMPLATE";
    const ACTION_MAIL_TEMPLATE_EDIT = "EDIT_MAIL_TEMPLATE";
    const ACTION_MAIL_TEMPLATE_DELETE = "DELETE_MAIL_TEMPLATE";
    
    const ACTION_USER_ARTICLE_ADD = "ADD_ARTICLE";
    const ACTION_USER_ARTICLE_EDIT = "EDIT_ARTICLE";
    const ACTION_USER_ARTICLE_DELETE = "DELETE_ARTICLE";

    const ACTION_USER_CACHE_SWITCH_ON = "SWITCH_CACHE_ON";
    const ACTION_USER_CACHE_SWITCH_OFF = "SWITCH_CACHE_OFF";
    const ACTION_USER_CACHE_CLEAR = "CLEAR_CACHE";
    
    const ACTION_USER_RESULT_EXPORT_OPEN_RESULT = "EXPORT_OPEN_RESULT";
    const ACTION_USER_RESULT_EXPORT_CUSTOMER_LIST = "EXPORT_CUSTOMER_LIST";
    const ACTION_USER_REPORT_EXPORT_CUSTOMER_EXTEND = "EXPORT_CUSTOMER_EXTEND";
    
    const ACTION_USER_OLYMPIC_ADD = "ADD_OLYMPIC";
    const ACTION_USER_OLYMPIC_EDIT = "EDIT_OLYMPIC";
    const ACTION_USER_OLYMPIC_DELETE = "DELETE_OLYMPIC";
    
    const ACTION_USER_TAG_ADD = "ADD_TAG";
    const ACTION_USER_TAG_EDIT = "EDIT_TAG";
    const ACTION_USER_TAG_DELETE = "DELETE_TAG";
    
    const ACTION_USER_PRODUCT_ADD = "ADD_PRODUCT";
    const ACTION_USER_PRODUCT_EDIT = "EDIT_PRODUCT";
    const ACTION_USER_PRODUCT_DELETE = "DELETE_PRODUCT";
    
    const ACTION_SCHEDULE_ADD = "ADD_SCHEDULE";
    const ACTION_SCHEDULE_EDIT = "EDIT_SCHEDULE";
    const ACTION_SCHEDULE_DELETE = "DELETE_SCHEDULE";
    
    const ACTION_SCHEDULE_REGISTER_ADD = "ADD_SCHEDULE_REGISTER";
    const ACTION_SCHEDULE_REGISTER_EDIT = "EDIT_SCHEDULE_REGISTER";
    const ACTION_SCHEDULE_REGISTER_DELETE = "DELETE_SCHEDULE_REGISTER";
        /**
     *
     */
    public function __construct() {
        $o_repository_manager = new Domain_Repositories_RepositoryManager;
        $this->_rep = $o_repository_manager->getActivityUserLogRepository();
    }

    /**
     *
     * @return <type>
     */
    public function load($id) {
        return $this->_rep->load($id);
    }

    /**
     *
     * @param <type> $offset
     * @param <type> $limit
     * @param <type> $filter
     * @param <type> $sort
     * @param <type> $count
     * @return <type>
     */
    public function load_all($is_count = false, $offset=null, $limit=null, $filter = null, $sort = null) {
        return $this->_rep->load_all($offset, $limit, $filter, $sort, $is_count);
    }

    /**
     *
     * @param Domain_Entities_Entity $o_entity
     * @return <type>
     */
    public function insert($o_entity) {
        return $this->_rep->insert_by($o_entity);
    }

    /**
     *
     * @param Domain_Entities_Entity $o_entity
     * @return <type>
     */
    public function update($o_entity) {
        return $this->_rep->update_by($o_entity);
    }

    /**
     *
     * @param <type> $id
     * @return <type>
     */
    public function delete($id) {
        return $this->_rep->delete_by($id);
    }

    /**
     *
     * @param <type> $action
     * @param <type> $target_id
     * @param <type> $customer_id
     */
    public function add_log($action,$target_id,$user_id) {
        $o_entity_activity_user_log = new Domain_Entities_Activity_User_Log();
        // insert log
        $o_entity_activity_user_log->setAction($action);
        $o_entity_activity_user_log->setTarget_id($target_id);
        $o_entity_activity_user_log->setIp($_SERVER["REMOTE_ADDR"]);
        $o_entity_activity_user_log->setUser_id($user_id);
        $o_entity_activity_user_log->setLog_time(date("Y-m-d H:i:s", strtotime('now')));
        $this->insert($o_entity_activity_user_log);
    }

}

?>
